home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14771 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  75 lines

  1. Path: news.nask.org.pl!usenet
  2. From: flssoft@blue.maloka.waw.pl (Grzegorz (FLS))
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Visual C++ help needed!!!!(please)
  5. Date: Mon, 01 Apr 1996 22:22:29 GMT
  6. Organization: Research and Academic Computer Network
  7. Message-ID: <4jph92$fq9@bilbo.nask.org.pl>
  8. References: <4jn1cn$7vo@crash.microserve.net> <4jnb8f$18u8@mule2.mindspring.com>
  9. NNTP-Posting-Host: s112.maloka.waw.pl
  10. X-Newsreader: Forte Free Agent v0.46
  11.  
  12. rudd@mindspring.com (Justin Rudd) wrote:
  13.  
  14. >ada105@psu.edu (Alexander Achey) wrote:
  15.  
  16. >>    Hi all,
  17. >>    I'm attempting to write a Visual C++ program in which I am making it
  18. >>come up with schedules of college courses.  I use a modal dialog box
  19. >>to get some information from the user and then I need to have it put
  20. >>this data somewhere I can use it after the box is closed.  I tried
  21. >>putting the variables under the public part of the document class, but
  22. >>I can't seem to use the GetDocument() function from the dialog box.
  23. >>Is there any other way to get access to the document's member
  24. >>functions or is there a better way to do this?  i tried declaring this
  25. >>as a global variable, but I really don't want to do that.  Besides, I
  26. >>keep getign redinifition errors when I do that.  I'd really
  27. >>apprecitate it if anyone could give me any kind of help.
  28.  
  29. >In your dialog class have a member function that accepts a pointer to
  30. >a CDocument.
  31.  
  32. >void CMyDialog::SetDocPtr(CMyDoc* pDoc)
  33. >{
  34. >    m_pDoc = pDoc;
  35. >}
  36.  
  37.  
  38. Hi Alexander and Justin,
  39.  
  40. I do not think, that declaring <SetDocPtr()> method is a good solution
  41. (however it is not bad anyway ;)).
  42. The solution, is to use local (public) members in CMyDialog dialog.
  43. For example
  44.  
  45. class CMyDialog : public CDialog
  46. {
  47. ....
  48. public: // input/outpu members
  49.     int m_int_var ;
  50.     CString m_string_var ;
  51.     // ... etc. Sorry for members names.
  52. }
  53.  
  54. When you want to use CMyDialog, you can do:
  55.  
  56. CMyDoc::OnEditMyDialog()
  57. {
  58.  CMyDialog dlg ;
  59.  
  60.     if ( dlg.DoModal() == IDOK )
  61.     {
  62.         // do something with dlg.m_int_var
  63.         // do something with dlg.m_string_var
  64.         // for example:
  65.         m_doc_int_var = dlg.m_int_var ;
  66.         m_doc_string_var = dlg.m_string_var ;
  67.     }
  68. }
  69.  
  70.  
  71. Regards,
  72. Grzegorz.
  73.  
  74.  
  75.